package com.elinkway.infinitemovies.http.parser;

import com.elinkway.infinitemovies.bean.UserLoginBean;

import org.json.JSONObject;

/**
 * Created by xiaojian on 16-3-9.
 */
public class UserLoginParser extends LVideoMobileParser<UserLoginBean> {
    @Override
    public UserLoginBean parse(JSONObject data) throws Exception {
        UserLoginBean userLoginBean = null;
        if(data != null){
            userLoginBean = new UserLoginBean();
            String code = super.getCode();
            String msg = super.getMsg();
            if("200".equals(super.getCode())){
                JSONObject dataObj = data;
                if(dataObj != null){
                    userLoginBean.setToken(dataObj.optString("token"));
                    userLoginBean.setIsFirst(dataObj.optString("is_first"));
                    userLoginBean.setUid(dataObj.optString("uid"));
                }
            }
            userLoginBean.setCode(code);
            userLoginBean.setMsg(msg);
        }
        return userLoginBean;
    }
}
